﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace RestaurantWebService
{
    [WebService(Namespace = "http://rotana.org/RestaurantWebService/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    public class RestaurantWebService : WebService, IRestaurantWebService
    {
        private OrderManager orderManager;
        private StatManager statManager;
        private OccupancyManager occupancyManager;

        public RestaurantWebService()
        {
            orderManager = new OrderManager();
            statManager = new StatManager();
            occupancyManager = new OccupancyManager();
        }

        [WebMethod]
        public Menu getMenu()
        {
            return Menu.Instance;
        }
        
        [WebMethod]
        public int placeOrder(Order order)
        {
            return orderManager.placeOrder(order);
        }

        [WebMethod]
        public Order getActiveOrder(int table, int chair)
        {
            return orderManager.getActiveOrder(table, chair);
        }

        [WebMethod]
        public List<Order> getActiveOrders(int table) 
        {
            return orderManager.getActiveOrders(table);
        }

        [WebMethod]
        public List<Order> getOrdersToBeDelivered()
        {
            return orderManager.getOrdersToBeDelivered();
        }

        [WebMethod]
        public void acknowledgeDelivery(Order order)
        {
            orderManager.acknowledgeDelivery(order);
        }

        [WebMethod]
        public List<Order> getPendingOrders()
        {
            return orderManager.getPendingOrders();
        }

        [WebMethod]
        public void indicateReady(Order order)
        {
            orderManager.indicateReady(order);
        }

        [WebMethod]
        public Meal getMostPopularMeal()
        {
            return statManager.getMostPopularMeal();
        }

        [WebMethod]
        public Table getMostPopularTable()
        {
            return statManager.getMostPopularTable();
        }

        [WebMethod]
        public int getNoOfAllMealSold()
        {
            return statManager.getNoOfAllMealSold();
        }

        [WebMethod]
        public int noOfMealSold(Meal meal)
        {
            return statManager.getNoOfMealSold(meal);
        }

        [WebMethod]
        public void markTableOccupancy(int table, bool occupied)
        {
            occupancyManager.markTableOccupancy(table, occupied);
        }

        [WebMethod]
        public bool getTableOccupancy(int table)
        {
            return occupancyManager.getTableOccupancy(table);
        }

        [WebMethod]
        public void markChairOccupancy(int table, int chair, bool occupied)
        {
            occupancyManager.markChairOccupancy(table, chair, occupied);
        }

        [WebMethod]
        public bool getChariOccupancy(int table, int chair)
        {
            return occupancyManager.getChariOccupancy(table, chair);
        }
    }
}
